package com.vooda.dao.sql;

import com.vooda.dto.bo.TestBO;
import org.apache.ibatis.jdbc.SQL;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;

/**
 * @author charlee
 * @date 2017/12/19
 */
public class TestSqlProvider {

    public String getTestList(TestBO testBO){
        return new SQL(){
            {
                SELECT("id,name,email");
                FROM("test");
                WHERE("1 = 1");
                if(!ObjectUtils.isEmpty(testBO) && StringUtils.hasText(testBO.getName())){
                    AND();
                    WHERE("name like concat('%', #{name}, '%')");
                }
            }
        }.toString();
    }
}
